package com.watson.demo.mybatis.controller;


import com.watson.demo.mybatis.annotation.ReadOnly;
import com.watson.demo.mybatis.entity.TUser;
import com.watson.demo.mybatis.service.TUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * // todo
 *
 * @author: llun
 * @date: 2022/2/14 14:58
 * @version: 1.0
 */
@RestController
@RequestMapping("tuser")
public class TUserController {
    private static final Logger logger = LoggerFactory.getLogger(TUserController.class);
    @Autowired
    TUserService tUserService;

    @GetMapping("insertTUser")
    public String insertTUser() {
        TUser tUser = new TUser();
        tUser.setName("ak");
        tUser.setAge(11);
        tUserService.save(tUser);
        logger.info("插入成功");
        return "success";
    }

    @GetMapping("listTUser")
    @ReadOnly
    public List<TUser> listTUser() {
        List<TUser> list = tUserService.list();
        logger.info("查询成功");
        return list;
    }
}
